package com.systop.entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.systop.validator.group.AddGroup;
import com.systop.validator.group.UpdateGroup;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Pattern;
import java.math.BigDecimal;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("sysuser")
public class SysUser {
  @TableId(type = IdType.INPUT)
  @NotNull(groups = {UpdateGroup.class},message = "修改用户信息需要指定用户")
  @Null(groups = {AddGroup.class},message = "添加用户不能指定ID")
  private Long userId;
  /**
   * 用户账号
   * 添加时userCode不能为空(包含空格)
   */
  @NotBlank(groups = {AddGroup.class},message = "用户账号不能为空(也不能包含空格)")
  @Null(groups = {UpdateGroup.class},message = "用户账号不能修改")
  private String userCode;
  /**
   * 用户昵称
   * 添加时userName不能为空(包含空格)
   */
  // @NotBlank(groups = {AddGroup.class},message = "用户名不能为空(也不能包含空格)")
  private String userName;
  /**
   * 用户密码
   * 添加时userPass不能为空(包含空格)
   */
  @NotBlank(groups = {AddGroup.class,UpdateGroup.class},message = "密码不能为空(也不能包含空格)")
  private String userPass;

  /**
   * 用户手机号
   */
  private String userPhone;

  /**
   * 用户邮箱
   */
  private String userEmail;

  /**
   * 用户钱包
   */
  @Min(value = 0,message = "用户余额必须大于等于0")
  private BigDecimal wallet;

  @NotNull(groups = {AddGroup.class},message = "需要添加状态")
  @Pattern(regexp = "^[01]*$",message = "状态不符合规格")
  private Integer status;

  @NotNull(groups = {AddGroup.class},message = "需要添加权限")
  @Pattern(regexp = "^[012]*$",message = "权限不符合规格")
  private Integer role;

  private String headPhoto;

  @TableField(exist = false)
  private int start;

  @TableField(exist = false)
  private int pageSize;

  @Null(groups = {AddGroup.class,UpdateGroup.class},message = "参数格式校验失败")
  private String salt;
}



